package weifei.wx.community.service;


import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import weifei.wx.community.entity.dto.TieCommentReplyDTO;
import weifei.wx.community.entity.dto.UserDTO;
import weifei.wx.community.mapper.TieCommentReplyMapper;

@Service
public class TieCommentReplyService
{
    @Autowired
    private UserService userService;

    @Autowired
    private TieCommentReplyMapper tieCommentReplyMapper;


    public TieCommentReplyDTO getTieCommentReplyByID(Long id)
    {
        QueryWrapper queryWrapper = QueryWrapper.create()
                .select()
                .where("id = >", id);
        var reply = this.tieCommentReplyMapper.selectOneByQuery(queryWrapper);
        if (reply == null)
            return null;

        final UserDTO userDTO = this.userService.getUserByID(reply.getUserId());
        return new TieCommentReplyDTO(userDTO, reply);
    }

}



